package com.yanqu.road.server.manager.union;

import com.yanqu.road.pb.union.cross.CrossUnionProto;
import com.yanqu.road.utils.date.DateHelper;

import java.util.List;

public class CrossActivityUnionGroupAbilityRankInfo {
    private int groupId;
    private long updateTime;
    private int activityId;
    private long activityEndTime;
    private CrossUnionProto.CrossUnionGetMaxAbilityUnionRankListResp.Builder rankMsg;

    public CrossActivityUnionGroupAbilityRankInfo(int activityId, int groupId) {
        this.activityId = activityId;
        rankMsg = CrossUnionProto.CrossUnionGetMaxAbilityUnionRankListResp.newBuilder();
        rankMsg.setActivityId(activityId);
        updateTime = DateHelper.getCurrentTime();
        rankMsg.setUpdateTime(updateTime);
    }

    public boolean isNeedUpdate() {
        if (rankMsg.getRankCount() == 0) {
            return true;
        }

        if (DateHelper.getCurrentTime() - updateTime > 10 * DateHelper.SECOND_MILLIONS) { // 10秒更新一次
            return true;
        }

        return false;
    }

    public CrossUnionProto.CrossUnionGetMaxAbilityUnionRankListResp.Builder getRankMsg() {
        return rankMsg;
    }

    public void setRankMsg(CrossUnionProto.CrossUnionGetMaxAbilityUnionRankListResp.Builder rankMsg) {
        this.rankMsg = rankMsg;
        this.updateTime = DateHelper.getCurrentTime();
    }

    public long getActivityEndTime() {
        return activityEndTime;
    }

    public void setActivityEndTime(long activityEndTime) {
        this.activityEndTime = activityEndTime;
    }

    public int getActivityId() {
        return activityId;
    }
}
